package com.ihg.hiex.admin.web.controller.session.during;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.demo2do.core.web.interceptor.MenuSetting;
import com.ihg.hiex.admin.service.session.SessionMeetingService;
import com.ihg.hiex.admin.service.session.SessionService;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.meeting.SessionMeeting;
import com.ihg.hiex.entity.user.Assessor;
import com.ihg.hiex.entity.user.Delegate;

/**
 * 
 * @author dan
 *
 */
@Controller
@RequestMapping("/sessions/{sessionId}")
@MenuSetting("menu-sessions")
public class ClosingSessionController {
    
    @Autowired
    private SessionService sessionService;
    
    @Autowired
    private SessionMeetingService sessionMeetingService;
    
    /**
     * Day Three Coach Skill recap
     * 
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-three")
    @RequestMapping(path = "/assessor-closing-session", method = RequestMethod.GET)
    public ModelAndView assessorIndex(@PathVariable("sessionId") Long sessionId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/closing-session/assessor-closing-session");

        // 1. load session
        Session session = sessionService.load(Session.class, sessionId);
        modelAndView.addObject("session", session);
        
        // 2. load meeting
        SessionMeeting meeting = sessionMeetingService.load(session, "Assessor closing session");
        modelAndView.addObject("meeting", meeting);
        
        // 3. list delegate
        List<Assessor> assessors = sessionService.listAssessor(session);
        modelAndView.addObject("assessors", assessors);
        
        return modelAndView;
        
    }
    
    /**
     * 
     * @param sessionId
     * @return
     */
    @MenuSetting(value = "submenu-session-during-day-three")
    @RequestMapping(path = "/delegate-closing-session", method = RequestMethod.GET)
    public ModelAndView delegateIndex(@PathVariable("sessionId") Long sessionId) {
        
        ModelAndView modelAndView = new ModelAndView("session/during/closing-session/delegate-closing-session");

        // 1. load session
        Session session = sessionService.load(Session.class, sessionId);
        modelAndView.addObject("session", session);
        
        // 2. load meeting
        SessionMeeting meeting = sessionMeetingService.load(session, "Delegate closing session");
        modelAndView.addObject("meeting", meeting);
        
        // 3. list delegate
        List<Delegate> delegates = sessionService.listDelegate(session);
        modelAndView.addObject("delegates", delegates);
        
        return modelAndView;
        
    }
    
}
